home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / syscall / RCS / Fs_Write.c,v < prev    next >
Encoding:
Text File  |  1991-12-09  |  3.4 KB  |  137 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  sprited:1.2.1;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     88.06.21.11.14.55;  author ouster;  state Exp;
  11. branches 1.2.1.1;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     88.06.19.14.29.14;  author ouster;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19. 1.2.1.1
  20. date     91.12.08.17.05.59;  author kupfer;  state Exp;
  21. branches ;
  22. next     ;
  23.  
  24.  
  25. desc
  26. @@
  27.  
  28.  
  29. 1.2
  30. log
  31. @Cleanup header usage.
  32. @
  33. text
  34. @/* 
  35.  * Fs_Write.c --
  36.  *
  37.  *    Source code for the Fs_Write library procedure.
  38.  *
  39.  * Copyright 1988 Regents of the University of California
  40.  * Permission to use, copy, modify, and distribute this
  41.  * software and its documentation for any purpose and without
  42.  * fee is hereby granted, provided that the above copyright
  43.  * notice appear in all copies.  The University of California
  44.  * makes no representations about the suitability of this
  45.  * software for any purpose.  It is provided "as is" without
  46.  * express or implied warranty.
  47.  */
  48.  
  49. #ifndef lint
  50. static char rcsid[] = "$Header: Fs_Write.c,v 1.1 88/06/19 14:29:14 ouster Exp $ SPRITE (Berkeley)";
  51. #endif not lint
  52.  
  53. #include <sprite.h>
  54. #include <status.h>
  55. #include <fs.h>
  56.  
  57.  
  58. /*
  59.  *----------------------------------------------------------------------
  60.  *
  61.  * Fs_Write --
  62.  *
  63.  *      The "normal" Fs_Write interface for user code.  Writes writeLength
  64.  *      characters from buffer to the file identified by streamID.
  65.  *      *amtWrittenPtr is updated to reflect how much data were actually
  66.  *      written.
  67.  *
  68.  *      For some kinds of devices, Fs_Write causes the calling process to
  69.  *      block until the device is ready to accept the data.  If a signal
  70.  *      is received by the process while it is blocked, then the
  71.  *      Fs_RawWrite system call will be aborted in order to process the
  72.  *      signal.  When (if) the signal returns, the system call will return
  73.  *      a GEN_ABORTED_BY_SIGNAL status, and *writeCountPtr will reflect
  74.  *      the number of bytes accepted by the device before the signal
  75.  *      occurred.  This routine will detect this occurrence and
  76.  *      automatically restart the system call to write the remainder of
  77.  *      the data.
  78.  *
  79.  * Results:
  80.  *    An error code.
  81.  *
  82.  * Side effects:
  83.  *    The file offset is incremented to be after the data written.
  84.  *    The amtWrittenPtr is updated to reflect the amount actually written.
  85.  *
  86.  *----------------------------------------------------------------------
  87.  */
  88.  
  89. ReturnStatus
  90. Fs_Write(streamID, writeLength, buffer, amtWrittenPtr)
  91.     int        streamID;    /* The user's index into its open file list */
  92.     int        writeLength;    /* The amount of bytes to write */
  93.     Address    buffer;        /* The data to be written */
  94.     int        *amtWrittenPtr;    /* The amount of bytes actually written */
  95. {
  96.     int amtWritten;
  97.     ReturnStatus status;
  98.  
  99.     *amtWrittenPtr = 0;
  100.     do {
  101.     status = Fs_RawWrite(streamID, writeLength, buffer, &amtWritten);
  102.     *amtWrittenPtr += amtWritten;
  103.     if (status == GEN_ABORTED_BY_SIGNAL) {
  104.         writeLength -= amtWritten;
  105.         if (writeLength <= 0) {
  106.         return(SUCCESS);
  107.         }
  108.         buffer += amtWritten;
  109.     }
  110.     } while (status == GEN_ABORTED_BY_SIGNAL);
  111.     return(status);
  112. }
  113. @
  114.  
  115.  
  116. 1.2.1.1
  117. log
  118. @Initial branch for Sprite server.
  119. @
  120. text
  121. @d17 1
  122. a17 1
  123. static char rcsid[] = "$Header: /sprite/src/lib/c/syscall/RCS/Fs_Write.c,v 1.2 88/06/21 11:14:55 ouster Exp $ SPRITE (Berkeley)";
  124. @
  125.  
  126.  
  127. 1.1
  128. log
  129. @Initial revision
  130. @
  131. text
  132. @d17 1
  133. a17 1
  134. static char rcsid[] = "$Header: proto.c,v 1.2 88/03/11 08:39:08 ouster Exp $ SPRITE (Berkeley)";
  135. d21 1
  136. @
  137.